//! $Id$
//!
//! @File    BindValueContext.h
//! @Author  Johan Andersson <skagget77@gmail.com>
//! @Date    Thu Oct 01 20:03 2009
//! @Ingroup IoCppDetail

#if !defined(IOCPP_BINDVALUECONTEXT_H)
#define IOCPP_BINDVALUECONTEXT_H

#include "IoCpp/Detail/ValueContext.h"

#include <boost/shared_ptr.hpp>
#include <string>

namespace IoCpp
{
namespace Detail
{
   //!
   //! @author  Johan Andersson <skagget77@gmail.com>
   //! @date    Thu Oct 01 20:03 2009
   //! @ingroup IoCppDetail
   //!
   //! The BindValueContext class, encapsulates the operations that can be
   //! chained to a BindValue configuration call.
   //!
   template<class T1>
   class BindValueContext 
   {
   public :
      //!
      //! Creates a new instance of the BindValueContext class.
      //!
      //! @param context The ValueContext instance holding the state of the
      //!                configuration operation.
      //!
      BindValueContext( boost::shared_ptr<ValueContext<T1> > context );

      //!
      //! Binds the specified constant to the context.
      //!
      //! @param constant The constant to bind to the context.
      //!
      void ToConstant( T1 constant );

      //!
      //! Binds the specified provider to the context.
      //!
      //! @param provider The provider to bind to the context.
      //!
      template<class T2>
      void ToProvider( T2 provider );

   private :
      boost::shared_ptr<ValueContext<T1> > context;
   };


   template<class T1>
   BindValueContext<T1>::BindValueContext( boost::shared_ptr<ValueContext<T1> > context ) 
      : context(context) {
   }


   template<class T1>
   void BindValueContext<T1>::ToConstant( T1 constant ) {
      context->SetConstant(constant);
   }


   template<class T1>
   template<class T2>
   void BindValueContext<T1>::ToProvider( T2 provider ) {
      context->SetProvider(provider);
   }
}
}

#endif   // IOCPP_BINDVALUECONTEXT_H
